import Vue from 'vue'

export default Vue.mixin({
	methods: {
		tipsOpen() {
			this.$alert('您的账号和密码未填写完成，请重新填写', '提示', {
				confirmButtonText: '确定',
				callback: action => {
					this.$message({
						type: 'info',
						message: `请重新填写`
					});
				}
			});
		},
		async loadList(name, attribute,pageSize=8,pageNo=1) {
			var url = this.$apis[name];
			var rs = await this.$http.get(url,{pageSize,pageNo});
			this[attribute] = rs.data;
			// console.log([attribute])
		},
		 deletAction(url,pramas={},messages,callsback){
			 var action = ()=>{
				this.$http.post(this.$apis[url],pramas).then(()=>{
					callsback();
				});
			}
			this.deleteOpen(action,messages)
		},
		deleteOpen(action,messages) {
			this.$confirm(`此操作将${messages}, 是否继续?`, '提示', {
				confirmButtonText: '确定',
				cancelButtonText: '取消',
				type: 'warning'
			}).then( () => {
				 action();
				this.$message({
					type: 'success',
					message: '删除成功!'
				});
			}).catch(() => {
				this.$message({
					type: 'info',
					message: '已取消删除'
				});
			});
		},
	},
	fileter:{
		formate(data){
			var d = new Data(data);
			return d.getFullYear() + "-" + (d.getMonth() + 1) + "-" + d.getDay()
		}
	}
})
